package com.awenhui.demo.task;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Set;

/**
 * @author yuxf
 * @version 1.0
 * @date 2021/6/29 14:08
 */
@Component
@Order(2)
public class MyApplicationRunner implements ApplicationRunner {
    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("====ApplicationRunner====");
        System.out.println("原始参数："+ Arrays.asList(args.getSourceArgs()) );
        Set<String> optionNames = args.getOptionNames();
        for (String optionName : optionNames) {
            System.out.println("解析后的key:"+optionName+",value:"+args.getOptionValues(optionName));
        }

    }
}
